# 1.导包
import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait

# 2.打开浏览器（创建浏览器驱动对象）
path = r"C:\Program Files\Python311\chromedriver.exe"
ser = Service(executable_path=path)  # Chrome浏览器驱动服务对象
driver = webdriver.Chrome(service=ser)  # 打开Chrome浏览器
# 3.输入网址
driver.get("http://121.43.169.97:8081/common/member/login")
# 4.页面操作
driver.find_element(By.ID, value='keywords').send_keys('15532542150')
driver.find_element(By.ID, value='password').send_keys('1q2w3e')
driver.find_element(By.ID, value='login-btn').click()
WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, "//em[text()='借款账户']"))).click()
WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.LINK_TEXT, '申请额度'))).click()
WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.ID, "amount_account"))).send_keys('200000')
driver.find_element(By.NAME, 'remark').send_keys('贷款让刀哥开演唱会')
driver.find_element(By.NAME, 'verifycode').send_keys('8888')
driver.find_element(By.CSS_SELECTOR, '.btn-submit.btn-md').click()

# 5.等待2秒
time.sleep(2)
# 6.退出浏览器
driver.quit()
